/*
<Copyright (C) 2011 Dru Moore>

This file is part of demorecorder.

vlc-remote is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

demorecorder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with demorecorder.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RECORDPIPELINE_H
#define RECORDPIPELINE_H

#include <QObject>
#include <QString>
#include <gst/gst.h>

class RecordPipeline : public QObject
{
    Q_OBJECT
public:
    explicit RecordPipeline(QObject *parent = 0);
    bool is_bouncing;
    RecordPipeline(QString name, QString location, GstElement *src, GstCaps *caps, QString encoder_element);
    ~RecordPipeline();

signals:
    void position_duration(long long position, long long duration);
    void end_of_stream();
    void stream_error(QString msg);

public slots:
    bool set_src(GstElement *src);
    void clear_src();
    bool set_location(QString location);
    QString get_location();
    void get_duration_info();
    void record();
    void stop();

private:
    void construct_pipeline();
    void teardown_pipeline();
    long long get_current_time();

    GstPipeline *pipeline;
    GstElement *src;
    GstElement *queue;
    GstElement *resampler;
    GstElement *encoder;
    GstElement *converter;
    GstElement *filesink;
    GstCaps *caps;
    GstQuery *duration_query;
    GstQuery *position_query;
    QString location;
    QString encoder_element;
    long long start_time;
    long long position;
    long long duration;

};

#endif // RECORDPIPELINE_H
